//
//  UITableView+Extension.swift
//  SwiiftProject
//
//  Created by Apple on 2019/5/13.
//  Copyright © 2019 lazyloading. All rights reserved.
//

import UIKit

extension UITableView{

    
    func registerNib(_ nibName : String,_ cellID : String) -> Void {
    
        self.register(UINib.init(nibName: nibName, bundle: nil), forCellReuseIdentifier: cellID);
    }
    
    /**最后一组*/
    var lastSection : NSInteger{
        return self.numberOfSections > 0 ? self.numberOfSections - 1 : 0;
    }
    
    /**最后一个cell indexPath*/
    var lastCellIIndexPath : IndexPath{
        let lastSection = self.lastSection;
        return IndexPath.init(row: self.lastCellIndexPathWithSection(lastSection).row, section: lastSection);
    }
    
    /**某一组最后一个cell indexPath*/
    func lastCellIndexPathWithSection(_ section : NSInteger) -> IndexPath {
        return IndexPath.init(row:self.numberOfRows(inSection: section)-1 , section: section);
    }
}
